package com.ktkq.service.academy.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ktkq.dao.academy.AcademyMapper;
import com.ktkq.service.academy.AcademyService;
import com.ktkq.util.PageFinder;
import com.ktkq.util.Pageing;
import com.ktkq.util.TimeUtil;
import com.ktkq.util.font.UploadExcel;
import com.ktkq.vo.Academy;


@Service("academyService")
@Transactional
public class AcademyServiceImpl implements AcademyService{

	@Autowired
	AcademyMapper academyMapper;
	
	@Override
	public PageFinder<Academy> queryList(Pageing pageing) {
		
		PageFinder<Academy> pageFinder = new PageFinder<Academy>();
		
		pageFinder.setRowCount(academyMapper.pageCount());
		pageFinder.setDataList(academyMapper.queryList(pageing));
		
		return pageFinder;
	}

	@Override
	public void insert(Academy t) {
		
		academyMapper.insert(t);
	}

	@Override
	public void update(Academy t) {
		
		academyMapper.update(t);
	}

	@Override
	public void delete(Academy t) {
		
		academyMapper.delete(t);
	}

	@Override
	public List<Academy> queryListById(int id) {
		
		return academyMapper.queryById(id);
	}

	@Override
	public List<Academy>  UploadExcel(String filePath,Academy t) {
		
		List<Academy>  lss = new ArrayList<Academy>();
	List<List<String>> list = new UploadExcel(filePath).AnalysisExcel();
	 if(list.size()!=0){
		 String time = new TimeUtil().getTime();
		 for(List<String> ls :list){
			 Academy academy = new Academy();			
			     academy.setAcademy(ls.get(1));
			     academy.setTime(time);
				 lss.add(academy);
				 academyMapper.insert(academy); 
		 } 
		
	 }
	
	return lss;
	}

	
	
}
